package yxy.game.pm2.command.kow;

import yxy.cherry.game.base.message.MessageEmitterHandler;
import yxy.cherry.game.base.message.annotation.MessageSource;
import yxy.cherry.game.base.message.annotation.MessageType;
import yxy.game.pm2.Result;
import yxy.game.pm2.command.Command;
import yxy.game.pm2.message.KowMessage;
import yxy.game.pm2.module.kow.KowHandle;

/**
 * 天下第一 天下第一界面
 */
@MessageType(proto = Command.KowUI, classtype = KowMessage.KowUIRequest.class)
public class CMD_KowUI extends Command<KowMessage.KowUIRequest> {

    @Override
    public void execute(MessageSource messageSource, KowMessage.KowUIRequest request) {
        String playerCode = messageSource.getTag();

        KowMessage.KowUIResponse.Builder response = KowMessage.KowUIResponse.newBuilder();

        // XXX TEST
//		new KowFuture().update(KowModule.get(2));

        Result result = new KowHandle().mainInfo(playerCode, response);

        send(messageSource, response, result);
    }

    private void send(MessageSource messageSource, KowMessage.KowUIResponse.Builder response, Result result) {
        response.setResult(result.packResult());
        MessageEmitterHandler.getInstance().send(messageSource, response.build());
    }
}